home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Floppyshop 2
/
Floppyshop - 2.zip
/
Floppyshop - 2.iso
/
art&graf.ix
/
art-0012
/
shendraw
/
shendraw.pas
next >
Wrap
Pascal/Delphi Source File
|
1997-04-16
|
40KB
|
1,179 lines
PROGRAM Menu_Example ;
CONST
{$I gemconst}
TYPE
{$I gemtype}
letter_num = string[4];
pos_actions = (nothing, point_action, line_action, rect_action,
rd_rect_action, circle_action,
text_action, preset_action, insert_action);
VAR
menu : Menu_Ptr ;
file_title,
open_item,
load_item,
save_item,
close_item,
fsep_item,
quit_item,
actions_title,
point_item,
line_item,
rect_item,
rd_rect_item,
circle_item,
text_item,
preset_item,
asep0_item,
insert_item,
nothing_item,
asep1_item,
showxy_item,
grid_item,
asep2_item,
erase_item : integer;
predef_title : integer;
square_item,
pcircle_item,
arrow_item : array [1..3] of integer;
mode_title,
frame_item,
fill_item,
msep0_item,
black_item,
white_item,
red_item,
green_item,
msep1_item,
out_true_item,
out_false_item,
msep2_item,
replace_item,
transp_item,
xor_item,
reverse_item,
text_title,
normal_item,
bold_item,
italic_item,
under_item,
outline_item,
shadow_item,
line_title,
solid_item,
longdash_item,
dots_item,
ddots_item,
dash_item,
ddd_item,
paintstyle_title,
m1_item,
m2_item,
m3_item,
m4_item,
m5_item,
m6_item,
m7_item,
psep1_item,
n1_item,
n2_item,
n3_item,
n4_item,
n5_item,
wind_title : integer;
wind_item : array [1..4] of integer;
dummy : integer ;
actions : pos_actions;
start_figure,
b_showxy,
b_normal,
b_bold,
b_italic,
b_under,
b_outline,
b_shadow,
b_save,
b_frame : boolean;
b_arrow,
b_square,
b_pcircle : array [1..5] of boolean;
b_shapes : array [1..12] of boolean;
draw_type,
draw_window : array [1..4] of integer;
g_info_bar,
draw_title : window_title;
act_window : integer;
x, y, w, h,
curx, cury,
oldx, oldy : integer;
alert : string;
cur_outline : boolean;
mul,
mul_number,
cur_paint_style,
cur_line_style,
cur_text_style,
cur_color,
cur_font,
cur_draw_mode : integer;
preset_string : string;
copyright : str255;
screen_w, screen_h,
total_cols, total_rows,
char_width, char_heigth,
col, row,
first_col, first_row,
xy_col
: integer;
xm, ym : integer;
{ memory of parameters at all times
1 what action is taking place : actions (set of ...)
2 if predef what predefined figure :
4 user strings if any : user_string
5 modes : frame or fill : b_frame (true or false)
6 black or white : cur_color (black or white)
7 outline true or false : cur_outline (true or false)
8 what draw_mode (1-4) : cur_draw_mode (1 to 4)
9 text mode (1-6) : cur_text_style( 1 to 6)
10 line style (1-6) : cur_line_style (1 to 6)
11 painstyle (1-35) : cur_paint_style( 1 to 35)
}
{$I gemsubs}
procedure TAOLOGO;
var
i, limit, maxi,
midx, midy,
tao_radius,
midy_up,
midy_dn,
radius2,
radius3 : integer;
x,y,w,h,
mid_screen_x,
vertical : integer;
procedure WAIT(n : integer);
var i, j : integer;
begin
for i := 1 to n do
for j := 1 to 32000 do;
end;
begin
{ clear_screen; }
limit := 0;
maxi := 10;
draw_mode(1);
paint_style(solid);
work_rect(0,x,y,w,h);
set_clip(0,0,w,h+y);
mid_screen_x := w div 2;
vertical := h+y;
for i := 1 to maxi do
begin
clear_screen;
tao_radius := i * (100 div maxi);
tao_radius := tao_radius div 2;
midx := (mid_screen_x div maxi) * i;
midy := vertical - (( (vertical div 8 * 5) div maxi ) * i);
midy_up := midy - (tao_radius div 2);
midy_dn := midy + (tao_radius div 2);
radius2 := tao_radius div 2;
radius3 := radius2 div 2;
frame_oval (midx, midy, tao_radius, tao_radius);
frame_oval (midx, midy, tao_radius+1, tao_radius+1);
paint_color( black );
paint_arc (midx, midy, tao_radius, tao_radius, 2700, 3600 );
paint_arc (midx, midy, tao_radius, tao_radius, 0, 900 );
paint_color( white );
paint_oval (midx, midy_up, radius2, radius2);
paint_color( black );
paint_oval (midx, midy_dn, radius2, radius2);
paint_color( black );
paint_oval (midx, midy_up, radius3, radius3);
paint_color( white );
paint_oval (midx, midy_dn, radius3, radius3);
end; { for }
wait(3);
text_style(thickened|underlined);
draw_string( 190, vertical div 40 * 33,
' S H E N D R A W E R ');
wait(3);
text_style(outlined);
draw_string( 110, vertical div 40 * 36,
'Something Else Inc. Mirissa Sri Lanka');
wait(10);
text_style(normal);
end;
procedure INT_TO_STR(num : integer; VAR numstr : letter_num);
{ transforms an integer in a 3-character string }
var n : integer;
a,b,c,dummy : char;
procedure first;
begin
a := '0';
b := '0';
c := chr(ord(num) + 48);
end;
procedure second;
begin
a := '0';
b := chr(ord(num div 10)+ 48);
c := chr(ord(num mod 10)+ 48);
end;
procedure third;
begin
a := chr(ord(num div 100)+ 48);
n := num mod 100;
b := chr(ord(n div 10)+ 48);
c := chr(ord(n mod 10)+ 48);
end;
begin
if num < 10
then first
else if num < 100
then second
else if num < 1000
then third;
numstr := concat(a,b,c);
end;
procedure ALERTBOX(str : str255);
var alert : str255;
begin
alert := concat ('[0][', str, '][ OK ]');
dummy := do_alert( alert, 1 ) ;
set_mouse(m_thin_cross);
end;
procedure SCREEN_CHAR_PARAM(win_handle : integer);
var x, y, w, h, cw, ch, dummy : integer;
begin
sys_font_size(cw, ch, dummy, dummy);
char_width := cw;
char_heigth := ch;
work_rect( win_handle, x, y, w, h ) ;
screen_w := w;
screen_h := h;
total_cols := screen_w div char_width;
total_rows := screen_h div char_heigth;
first_row := y + char_heigth;
first_col := x;
xy_col := screen_w - (12 * char_width);
end;
procedure CLEAR_WINDOW(win_handle : INTEGER);
var x, y, w, h : integer;
begin
hide_mouse;
work_rect( win_handle, x, y, w, h ) ;
set_clip( x, y, w, h ) ;
draw_mode(1);
paint_style( solid ) ;
paint_color( white ) ;
paint_rect( x, y, w, h ) ;
draw_mode( cur_draw_mode );
paint_style( cur_paint_style ) ;
paint_color ( cur_color );
show_mouse;
end;
function DECODE_KEY( key_word : integer) : char;
var i, kw, char_value : integer;
begin
kw := key_word & $00FF;
for i := 32 to 128 do
if kw & i = i
then char_value := i;
decode_key := chr(char_value);
end;
procedure DEF_WINDOW;
var i : integer;
begin
draw_type[1] := g_close|g_name;
draw_type[2] := draw_type[1]|g_uparrow|g_dnarrow;
draw_type[3] := g_all;
draw_type[4] := g_all|g_info;
draw_title := ' SHEN RISING DRAW AND PAINT PROGRAM ';
g_info_bar := ' This is the info bar ';
draw_window[1] := New_Window(draw_type[1], draw_title, 0,0,0,0);
draw_window[2] := New_Window(draw_type[2], draw_title, 0,0,0,0);
draw_window[3] := New_Window(draw_type[3], draw_title, 0,0,0,0);
draw_window[4] := New_Window(draw_type[4], draw_title, 0,0,0,0);
set_winfo(draw_window[4], g_info_bar);
end;
function SWITCH(var b : boolean) : boolean;
begin
if b = true
then b := false
else b := true;
switch := b;
end;
procedure SENTENCES;
var s : array [1..5] of string[30];
begin
s[1] := 'SHEN RISING DRAW PROGRAM|';
s[2] := ' Public Domain Software |';
s[3] := ' by Georges Khal |';
s[4] := ' Something Else Inc. |';
s[5] := ' Mirissa, Sri Lanka 1986';
copyright := concat(s[1], s[2], s[3], s[4], s[5]);
preset_string := 'This is a preset sentence to display';
end;
procedure DEF_MENU1;
begin
menu := New_Menu( 100, ' SHEN DRAW ');
file_title := Add_MTitle( menu, ' File ');
actions_title := Add_MTitle( menu, ' Figures ');
predef_title := Add_MTitle( menu, ' Predef. ');
mode_title := Add_MTitle( menu, ' Mode ');
text_title := Add_MTitle( menu, ' Text_St. ');
line_title := Add_MTitle( menu, ' Line_St. ');
paintstyle_title := Add_MTitle( menu, ' Paint_St. ');
wind_title := Add_MTitle( menu, ' WindType ');
save_item := Add_MItem( menu, file_title, ' Save ');
fsep_item := Add_MItem( menu, file_title, '--------');
quit_item := Add_MItem( menu, file_title, ' Quit ');
point_item := Add_MItem( menu, actions_title, ' Point ');
line_item := Add_MItem( menu, actions_title, ' Line ');
rect_item := Add_MItem( menu, actions_title, ' Rectangle ');
rd_rect_item := Add_MItem( menu, actions_title, ' Rnd Rect. ');
circle_item := Add_MItem( menu, actions_title, ' Circle ');
text_item := Add_MItem( menu, actions_title, ' Text ');
preset_item := Add_MItem( menu, actions_title, ' PreText ');
nothing_item := Add_MItem( menu, actions_title, ' Nothing ');
asep0_item := Add_MItem( menu, actions_title, '------------');
insert_item := Add_MItem( menu, actions_title, ' Insert ');
asep1_item := Add_MItem( menu, actions_title, '------------');
showxy_item := Add_MItem( menu, actions_title, ' Show x y ');
grid_item := Add_MItem( menu, actions_title, ' Grid ');
asep2_item := Add_MItem( menu, actions_title, '------------');
erase_item := Add_MItem( menu, actions_title, ' Erase Scr ');
square_item[1] := Add_MItem( menu, predef_title, ' Square1 ');
square_item[2] := Add_MItem( menu, predef_title, ' Square2 ');
square_item[3] := Add_MItem( menu, predef_title, ' Square3 ');
pcircle_item[1] := Add_MItem( menu, predef_title, ' Circle1 ');
pcircle_item[2] := Add_MItem( menu, predef_title, ' Circle2 ');
pcircle_item[3] := Add_MItem( menu, predef_title, ' Circle3 ');
arrow_item[1] := Add_MItem( menu, predef_title, ' Arrow1 ');
arrow_item[2] := Add_MItem( menu, predef_title, ' Arrow2 ');
arrow_item[3] := Add_MItem( menu, predef_title, ' Arrow3 ');
end;
procedure DEF_MENU2;
begin
frame_item := Add_MItem( menu, mode_title, ' Frame ');
fill_item := Add_MItem( menu, mode_title, ' Fill ');
msep0_item := Add_MItem( menu, mode_title, '----------');
black_item := Add_MItem( menu, mode_title, ' Black ');
white_item := Add_MItem( menu, mode_title, ' White ');
red_item := Add_MItem( menu, mode_title, ' Red ');
green_item := Add_MItem( menu, mode_title, ' Green ');
msep1_item := Add_MItem( menu, mode_title, '----------');
out_true_item := Add_MItem( menu, mode_title, ' Outl Tr ');
out_false_item := Add_MItem( menu, mode_title, ' Outl Fa ');
msep2_item := Add_MItem( menu, mode_title, '----------');
replace_item := Add_MItem( menu, mode_title, ' Replace ');
transp_item := Add_MItem( menu, mode_title, ' Transp. ');
xor_item := Add_MItem( menu, mode_title, ' Xor ');
reverse_item := Add_MItem( menu, mode_title, ' Reverse ');
normal_item := Add_MItem( menu, text_title, ' Normal ');
bold_item := Add_MItem( menu, text_title, ' Bold ');
italic_item := Add_MItem( menu, text_title, ' Italic ');
under_item := Add_MItem( menu, text_title, ' Underl. ');
outline_item := Add_MItem( menu, text_title, ' Outlined ');
shadow_item := Add_MItem( menu, text_title, ' Shadow ');
solid_item := Add_MItem( menu, line_title, ' Solid ');
longdash_item := Add_MItem( menu, line_title, ' Lg Dash ');
dots_item := Add_MItem( menu, line_title, ' Dotted ');
ddots_item := Add_MItem( menu, line_title, ' DashDot ');
dash_item := Add_MItem( menu, line_title, ' Dashed ');
ddd_item := Add_MItem( menu, line_title, ' DashDtDt ');
m1_item := Add_MItem( menu, paintstyle_title, ' 01 - 05 ');
m2_item := Add_MItem( menu, paintstyle_title, ' 06 - 10 ');
m3_item := Add_MItem( menu, paintstyle_title, ' 11 - 15 ');
m4_item := Add_MItem( menu, paintstyle_title, ' 16 - 20 ');
m5_item := Add_MItem( menu, paintstyle_title, ' 21 - 25 ');
m6_item := Add_MItem( menu, paintstyle_title, ' 26 - 30 ');
m7_item := Add_MItem( menu, paintstyle_title, ' 31 - 35 ');
psep1_item := Add_MItem( menu, paintstyle_title, '----------');
n1_item := Add_MItem( menu, paintstyle_title, ' + 0 ');
n2_item := Add_MItem( menu, paintstyle_title, ' + 1 ');
n3_item := Add_MItem( menu, paintstyle_title, ' + 2 ');
n4_item := Add_MItem( menu, paintstyle_title, ' + 3 ');
n5_item := Add_MItem( menu, paintstyle_title, ' + 4 ');
wind_item[1] := Add_MItem( menu, wind_title, ' Window1 ');
wind_item[2] := Add_MItem( menu, wind_title, ' Window2 ');
wind_item[3] := Add_MItem( menu, wind_title, ' Window3 ');
wind_item[4] := Add_MItem( menu, wind_title, ' Window4 ');
end;
procedure DEF_MENU3;
var i : integer;
begin
menu_disable (menu, fsep_item);
menu_disable (menu, asep0_item);
menu_disable (menu, asep1_item);
menu_disable (menu, asep2_item);
menu_disable (menu, msep0_item);
menu_disable (menu, msep1_item);
menu_disable (menu, msep2_item);
menu_check (menu, point_item, true);
menu_check (menu, square_item[1], true);
menu_check (menu, frame_item, true);
menu_check (menu, black_item, true);
menu_check (menu, out_true_item, true);
menu_check (menu, replace_item, true);
menu_check (menu, normal_item, true);
menu_check (menu, solid_item, true);
menu_check (menu, m1_item, true);
menu_check (menu, n1_item, true);
menu_check (menu, wind_item[1], true);
end;
PROCEDURE DEFINITIONS;
begin
def_menu1;
def_menu2;
def_menu3;
sentences;
end;
procedure ADJUST_PARAM;
begin
text_color( cur_color);
line_color( cur_color);
paint_color( cur_color);
draw_mode( cur_draw_mode);
text_style( cur_text_style);
line_style( cur_line_style);
paint_outline(cur_outline);
paint_style( cur_paint_style);
end;
procedure INIT_PARAM;
var i : integer;
begin
cur_color := black;
cur_draw_mode := 1;
cur_text_style := normal;
cur_line_style := 1;
cur_outline := true;
cur_paint_style := 1;
cur_font := system_font;
actions := point_action;
b_frame := true;
b_save := false;
b_showxy := false;
b_square[1] := true;
for i := 2 to 3 do
b_square[i] := false;
for i := 1 to 3 do
b_pcircle[i] := false;
for i := 1 to 3 do
b_arrow[i] := false;
adjust_param;
end;
procedure DO_GRID(win_handle : integer);
var x, y, w, h : integer;
begin
hide_mouse;
draw_mode(3);
paint_style(31);
paint_color( black ) ;
work_rect( win_handle, x, y, w, h ) ;
set_clip( x, y, w, h ) ;
paint_rect( x, y, w, h ) ;
paint_color(cur_color);
paint_style(cur_paint_style);
draw_mode( cur_draw_mode);
show_mouse;
end;
procedure SET_FILE_TITLE(item : integer);
begin
if item = save_item
then start_figure := true;
end;
procedure SET_ACTIONS_TITLE(item, x, y : integer);
var s : string[11];
begin
if item = erase_item
then begin
clear_window(draw_window[act_window]);
adjust_param;
end
else if item = showxy_item
then begin
if b_showxy
then begin
draw_mode(1);
s := ' ';
draw_string(xy_col, first_row, s);
draw_mode(cur_draw_mode);
end;
menu_check(menu, showxy_item, switch(b_showxy));
end
else if item = grid_item
then do_grid(draw_window[act_window])
else
begin
menu_check(menu, point_item, false);
menu_check(menu, line_item, false);
menu_check(menu, rect_item, false);
menu_check(menu, rd_rect_item, false);
menu_check(menu, circle_item, false);
menu_check(menu, text_item, false);
menu_check(menu, preset_item, false);
menu_check(menu, insert_item, false);
menu_check(menu, nothing_item, false);
menu_check(menu, item, true);
if item = point_item
then actions := point_action;
if item = line_item
then begin
actions := line_action;
{ oldx := x; oldy := y; }
end;
if item = rect_item
then actions := rect_action;
if item = rd_rect_item
then actions := rd_rect_action;
if item = circle_item
then actions := circle_action;
if item = text_item
then actions := text_action;
if item = preset_item
then actions := preset_action;
if item = insert_item
then actions := insert_action;
if item = nothing_item
then actions := nothing;
if actions in [ line_action, rect_action,
rd_rect_action, circle_action]
then start_figure := true;
end; { else }
end; { if action_title }
procedure SET_PREDEF_TITLE(item : integer);
var i : integer;
begin
for i := 1 to 3 do
menu_check(menu, square_item[i], false);
for i := 1 to 3 do
menu_check(menu, pcircle_item[i], false);
for i := 1 to 3 do
menu_check(menu, arrow_item[i], false);
menu_check(menu, item, true);
for i := 1 to 3 do
b_square[i] := false;
for i := 1 to 3 do
b_pcircle[i] := false;
for i := 1 to 3 do
b_arrow[i] := false;
for i := 1 to 3 do
if item = square_item[i]
then b_square[i] := true;
for i := 1 to 3 do
if item = pcircle_item[i]
then b_pcircle[i] := true;
for i := 1 to 3 do
if item = arrow_item[i]
then b_arrow[i] := true;
end;
procedure SET_MODE_TITLE(item : integer);
begin
if (item = frame_item) or (item = fill_item)
then begin
if item = frame_item
then begin
b_frame := true;
menu_check(menu, frame_item, true);
menu_check(menu, fill_item, false);
end;
if item = fill_item
then begin
b_frame := false;
menu_check(menu, frame_item, false);
menu_check(menu, fill_item, true);
end;
end;
if (item >= black_item) and (item <= green_item)
then begin
menu_check(menu, black_item, false);
menu_check(menu, white_item, false);
menu_check(menu, red_item, false);
menu_check(menu, green_item, false);
menu_check(menu, item, true);
if item = black_item
then cur_color := black;
if item = white_item
then cur_color := white;
if item = red_item
then cur_color := red;
if item = green_item
then cur_color := green;
adjust_param;
end;
if (item = out_true_item) or (item = out_false_item)
then begin
if item = out_true_item
then begin
menu_check(menu, out_true_item, true);
menu_check(menu, out_false_item, false);
cur_outline := true;
adjust_param;
end;
if item = out_false_item
then begin
menu_check(menu, out_true_item, false);
menu_check(menu, out_false_item, true);
cur_outline := false;
adjust_param;
end;
end;
if item >= replace_item
then begin
menu_check(menu, replace_item, false);
menu_check(menu, transp_item, false);
menu_check(menu, xor_item, false);
menu_check(menu, reverse_item, false);
menu_check(menu, item, true);
if item = replace_item
then cur_draw_mode := 1;
if item = transp_item
then cur_draw_mode := 2;
if item = xor_item
then cur_draw_mode := 3;
if item = reverse_item
then cur_draw_mode := 4;
adjust_param;
end;
end;
procedure SET_TEXT_TITLE(item : integer);
begin
if item = normal_item
then menu_check(menu, normal_item, switch(b_normal));
if item = bold_item
then menu_check(menu, bold_item, switch(b_bold));
if item = italic_item
then menu_check(menu, italic_item, switch(b_italic));
if item = under_item
then menu_check(menu, under_item, switch(b_under));
if item = outline_item
then menu_check(menu, outline_item, switch(b_outline));
if item = shadow_item
then menu_check(menu, shadow_item, switch(b_shadow));
cur_text_style := 0;
if b_normal
then cur_text_style := cur_text_style|normal;
if b_bold
then cur_text_style := cur_text_style|thickened;
if b_italic
then cur_text_style := cur_text_style|slanted;
if b_under
then cur_text_style := cur_text_style|underlined;
if b_outline
then cur_text_style := cur_text_style|outlined;
if b_shadow
then cur_text_style := cur_text_style|shadowed;
text_style(cur_text_style);
end;
procedure SET_LINE_TITLE(item : integer);
begin
menu_check(menu, solid_item, false);
menu_check(menu, longdash_item, false);
menu_check(menu, dots_item, false);
menu_check(menu, ddots_item, false);
menu_check(menu, dash_item, false);
menu_check(menu, ddd_item, false);
menu_check(menu, item, true);
if item = solid_item
then cur_line_style := solid;
if item = longdash_item
then cur_line_style := longdash;
if item = dots_item
then cur_line_style := dotted;
if item = ddots_item
then cur_line_style := dashdot;
if item = dash_item
then cur_line_style := dashed;
if item = ddd_item
then cur_line_style := dashdotdot;
adjust_param;
end;
procedure SET_STYLE_TITLE(item : integer);
begin
if item < n1_item
then begin
menu_check(menu, m1_item, false);
menu_check(menu, m2_item, false);
menu_check(menu, m3_item, false);
menu_check(menu, m4_item, false);
menu_check(menu, m5_item, false);
menu_check(menu, m6_item, false);
menu_check(menu, m7_item, false);
menu_check(menu, item, true);
if item = m1_item
then mul := 1;
if item = m2_item
then mul := 6;
if item = m3_item
then mul := 11;
if item = m4_item
then mul := 16;
if item = m5_item
then mul := 21;
if item = m6_item
then mul := 26;
if item = m7_item
then mul := 31;
cur_paint_style := mul + mul_number;
paint_style(cur_paint_style);
end
else begin
menu_check(menu, n1_item, false);
menu_check(menu, n2_item, false);
menu_check(menu, n3_item, false);
menu_check(menu, n4_item, false);
menu_check(menu, n5_item, false);
menu_check(menu, item, true);
if item = n1_item
then mul_number := 0;
if item = n2_item
then mul_number := 1;
if item = n3_item
then mul_number := 2;
if item = n4_item
then mul_number := 3;
if item = n5_item
then mul_number := 4;
cur_paint_style := mul + mul_number;
paint_style(cur_paint_style);
end;
end;
procedure SET_WIND_TITLE(item : integer);
var i, x, y, w, h : integer;
begin
for i := 1 to 4 do
menu_check(menu, wind_item[i], false);
menu_check(menu, item, true);
if not (item = wind_item[act_window])
then begin
close_window(draw_window[act_window]);
for i := 1 to 4 do
if item = wind_item[i]
then act_window := i;
open_window ( draw_window[act_window], 0,0,0,0 );
screen_char_param( draw_window[act_window] );
clear_window( draw_window[act_window] );
work_rect( draw_window[act_window], x, y, w, h ) ;
set_clip( x, y, w, h ) ;
adjust_param;
end;
end;
procedure INSERT_FIGURE;
const factor = 30;
var i : integer;
procedure DO_ARROW (size : integer);
var destx, desty, diff : integer;
begin
destx := curx + (size * factor);
desty := cury;
diff := (factor * size) div 5;
line(curx, cury, destx, desty);
line(destx - diff, cury - diff, destx, desty);
line(destx - diff, cury + diff, destx, desty);
move_to(curx, cury);
end;
begin
for i := 1 to 3 do
if b_square[i]
then if b_frame
then frame_rect(curx, cury, factor*i, factor*i)
else paint_rect(curx, cury, factor*i, factor*i);
for i := 1 to 3 do
if b_pcircle[i]
then if b_frame
then frame_oval(curx, cury, factor*i div 2, factor*i div 2)
else paint_oval(curx, cury, factor*i div 2, factor*i div 2);
for i := 1 to 3 do
if b_arrow[i]
then do_arrow(i);
end;
procedure TEXT_EVENT;
type but_press = (left, right);
var i, which, key,
dummy, xm, ym : integer ;
msg : Message_Buffer ;
finished : boolean;
letter : char;
start_text : boolean;
sentence : string;
begin
i := 0;
row := first_row;
col := first_col;
start_text := true;
finished := false;
while not finished do
begin
which := Get_Event( E_Message|E_keyboard|E_Button, 1,1,1,0,
false, 0, 0, 0, 0, false, 0, 0, 0, 0,
msg, key, dummy, dummy, xm, ym, dummy ) ;
if which & E_Keyboard <> 0
then begin
if not start_text
then begin
letter := decode_key(key);
if letter in [ chr(ord(32))..chr(ord(127)) ]
then begin
draw_string(col,row,letter);
col := col + char_width;
{ row := row + char_heigth;}
i := i + 1;
sentence[i] := letter;
end
else begin
start_text := true;
show_mouse;
end;
end;
end
else if which & E_Button <> 0
then begin
if start_text
then begin
col := xm;
row := ym;
start_text := false;
hide_mouse;
end
else begin
start_text := true;
finished := true;
show_mouse;
end;
end
else if which & E_Message <> 0
then if msg[0] = mn_selected
then menu_normal(menu, msg[3]);
end; { while }
end ; { text_event }
procedure EXECUTE_ACTION(x, y : integer);
var xval, yval : letter_num;
s : string;
samex, samey, r1, r2 : integer;
tempo1, tempo2 : real;
begin
if b_showxy
then begin
text_color(black);
line_color(black);
draw_mode(1);
text_style(normal);
int_to_str(x,xval);
int_to_str(y,yval);
s := concat('x=',xval,' y=',yval);
draw_string(screen_w - (12 * char_width), first_row, s);
adjust_param;
end;
hide_mouse;
case actions of
point_action :
begin
plot(x,y);
plot(x+1,y);
plot(x-1,y);
plot(x,y+1);
plot(x,y-1);
end;
line_action :
begin
if not start_figure
then begin
line(oldx, oldy, x, y);
oldx := x; oldy := y;
end
else start_figure := false;
end;
rect_action :
begin
if not start_figure
then begin
draw_mode(xor_mode);
if b_frame
then frame_rect(oldx, oldy, samex, samey)
else paint_rect(oldx, oldy, samex, samey);
end
else start_figure := false;
draw_mode(replace_mode);
if b_frame
then frame_rect(oldx, oldy, x-oldx, y-oldy)
else paint_rect(oldx, oldy, x-oldx, y-oldy);
samex := x-oldx; samey := y-oldy;
draw_mode(cur_draw_mode);
end;
rd_rect_action :
begin
if not start_figure
then begin
draw_mode(xor_mode);
if b_frame
then frame_round_rect(oldx, oldy, samex, samey)
else paint_round_rect(oldx, oldy, samex, samey);
end
else start_figure := false;
{ interesting effects
frame_round_rect(x, y, oldx, oldy)
paint_round_rect(x, y, oldx, oldy); }
draw_mode(replace_mode);
if b_frame
then frame_round_rect(oldx, oldy, x-oldx, y-oldy)
else paint_round_rect(oldx, oldy, x-oldx, y-oldy);
samex := x-oldx; samey := y-oldy;
draw_mode(cur_draw_mode);
end;
circle_action :
begin
if not start_figure
then begin
draw_mode(xor_mode);
if b_frame
then frame_oval(oldx, oldy, samex, samex)
else paint_oval(oldx, oldy, samex, samex);
end
else start_figure := false;
tempo1:= sqr( abs(x-oldx) ) + sqr( abs(y-oldy) );
tempo1 := abs ( tempo1 );
tempo2 := sqrt ( tempo1 );
r1 := trunc ( tempo2 );
draw_mode(replace_mode);
if b_frame
then frame_oval(oldx, oldy, r1, r1)
else paint_oval(oldx, oldy, r1, r1);
samex := r1;
draw_mode(cur_draw_mode);
end;
text_action :
begin
show_mouse;
text_event;
hide_mouse;
end;
preset_action :
begin
draw_string(curx, cury, preset_string);
end;
insert_action :
begin
insert_figure;
end;
nothing :
begin
end;
end; { case }
show_mouse;
end;
procedure DISPATCH(title, item, x, y : integer);
begin
if title = desk_title
then alertbox(copyright);
if title = file_title
then set_file_title(item);
if title = actions_title
then set_actions_title(item, x, y);
if title = predef_title
then set_predef_title(item);
if title = mode_title
then set_mode_title(item);
if title = text_title
then set_text_title(item);
if title = line_title
then set_line_title(item);
if title = paintstyle_title
then set_style_title(item);
if title = wind_title
then set_wind_title(item);
end;
procedure EVENT_LOOP;
var which, dummy : integer;
finished : boolean;
msg : message_buffer;
begin
finished := false;
while not finished do
begin
which := get_event( e_message|e_button, 1,1,1,0,
false, 0, 0, 0, 0, false, 0, 0, 0, 0,
msg, dummy, dummy, dummy, xm, ym, dummy ) ;
if which & e_message <> 0
then begin
start_figure := true;
if msg[0] = mn_selected
then if ((msg[3] = file_title) and (msg[4] = quit_item))
then finished := true
else dispatch(msg[3], msg[4], xm, ym);
menu_normal(menu, msg[3]);
end
else if which & e_button <> 0
then begin
curx := xm; cury := ym;
if start_figure
then begin
oldx := xm;
oldy := ym;
end;
execute_action(xm, ym);
end
else start_figure := true;
end; { while }
end ; { event_loop }
BEGIN { main }
if init_gem >= 0 then
begin
hide_mouse;
taologo;
definitions;
def_window;
clear_screen;
set_mouse( m_thin_cross );
show_mouse;
draw_menu( menu ) ;
act_window := 1;
open_window ( draw_window[act_window], 0,0,0,0 );
screen_char_param( draw_window[act_window] );
init_param;
clear_window( draw_window[act_window] );
work_rect( draw_window[act_window], x, y, w, h ) ;
set_clip( x, y, w, h ) ;
event_loop ;
close_window( draw_window[act_window] );
erase_menu( menu ) ;
set_mouse( m_arrow );
exit_gem ;
end;
END.